package Source;

import DAO.MySQLFlightDAO;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * The model for displayflights
 * @author Joshua and Jason
 */
public class DisplayFlights {

    private ArrayList<ArrayList<String>> FlightList;

    public ArrayList getFlightList() {
        return FlightList;
    }

    /**
     * Gets the flight data from the database
     * @return JPanel
     */
    public boolean getData() {
        //JPanel flightInfoPanel = new JPanel();
        MySQLFlightDAO flightInfo = new MySQLFlightDAO();
        if (flightInfo != null) {
            FlightList = flightInfo.getFlightsInfo();
            return true;
        }
        /* else {
        JPanel flightPanel = new JPanel();
        JPanel departurePanel = new JPanel();
        JLabel departureLabel = new JLabel("Departure: ");
        JLabel departureInfoLabel = new JLabel();
        
        JPanel departureDatePanel = new JPanel();
        JLabel departureDateLabel = new JLabel("Departure Date: ");
        JLabel departureDateInfoLabel = new JLabel();
        
        JPanel departureTimePanel = new JPanel();
        JLabel departureTimeLabel = new JLabel("Departure Time: ");
        JLabel departureTimeInfoLabel = new JLabel();
        
        JPanel destinationPanel = new JPanel();
        JLabel destinationLabel = new JLabel("Destination: ");
        JLabel destinationInfoLabel = new JLabel();
        
        JPanel arrivalDatePanel = new JPanel();
        JLabel arrivalDateLabel = new JLabel("Arrival Date: ");
        JLabel arrivalDateInfoLabel = new JLabel();
        
        JPanel arrivalTimePanel = new JPanel();
        JLabel arrivalTimeLabel = new JLabel("Arrival Time: ");
        JLabel arrivalTimeInfoLabel = new JLabel();
        
        JPanel seatsAvailablePanel = new JPanel();
        JLabel seatsAvailableLabel = new JLabel("Seats Available: ");
        JLabel seatsAvailableInfoLabel = new JLabel();
        
        JPanel pricePanel = new JPanel();
        JLabel priceLabel = new JLabel("Price: $");
        JLabel priceInfoLabel = new JLabel();
        
        JButton editFlightDetails = new JButton("Edit");
        
        departureInfoLabel.setText("Townsville");
        departureDateInfoLabel.setText("2009-02-12");
        departureTimeInfoLabel.setText("12:04:00");
        destinationInfoLabel.setText("Cairns");
        arrivalDateInfoLabel.setText("2009-02-12");
        arrivalTimeInfoLabel.setText("02:04:00");
        seatsAvailableInfoLabel.setText("3");
        priceInfoLabel.setText("199");
        
        flightPanel.add(departurePanel);
        departurePanel.add(departureLabel);
        departurePanel.add(departureInfoLabel);
        
        flightPanel.add(departureDatePanel);
        departureTimePanel.add(departureDateLabel);
        departureTimePanel.add(departureDateInfoLabel);
        
        flightPanel.add(departureTimePanel);
        departureTimePanel.add(departureTimeLabel);
        departureTimePanel.add(departureTimeInfoLabel);
        
        flightPanel.add(destinationPanel);
        destinationPanel.add(destinationLabel);
        destinationPanel.add(destinationInfoLabel);
        
        flightPanel.add(arrivalDatePanel);
        arrivalTimePanel.add(arrivalDateLabel);
        arrivalTimePanel.add(arrivalDateInfoLabel);
        
        flightPanel.add(arrivalTimePanel);
        arrivalTimePanel.add(arrivalTimeLabel);
        arrivalTimePanel.add(arrivalTimeInfoLabel);
        
        flightPanel.add(seatsAvailablePanel);
        seatsAvailablePanel.add(seatsAvailableLabel);
        seatsAvailablePanel.add(seatsAvailableInfoLabel);
        
        flightPanel.add(pricePanel);
        pricePanel.add(priceLabel);
        pricePanel.add(priceInfoLabel);
        
        flightPanel.add(editFlightDetails);
        flightPanel.setVisible(true);
        
        flightInfoPanel.add(flightPanel);
        
        
        departureInfoLabel.setText("Townsville");
        departureDateInfoLabel.setText("2009-03-10");
        departureTimeInfoLabel.setText("05:20:00");
        destinationInfoLabel.setText("Rockhampton");
        arrivalDateInfoLabel.setText("2009-03-10");
        arrivalTimeInfoLabel.setText("08:04:00");
        seatsAvailableInfoLabel.setText("54");
        priceInfoLabel.setText("284");
        
        flightPanel.add(departurePanel);
        departurePanel.add(departureLabel);
        departurePanel.add(departureInfoLabel);
        
        flightPanel.add(departureDatePanel);
        departureTimePanel.add(departureDateLabel);
        departureTimePanel.add(departureDateInfoLabel);
        
        flightPanel.add(departureTimePanel);
        departureTimePanel.add(departureTimeLabel);
        departureTimePanel.add(departureTimeInfoLabel);
        
        flightPanel.add(destinationPanel);
        destinationPanel.add(destinationLabel);
        destinationPanel.add(destinationInfoLabel);
        
        flightPanel.add(arrivalDatePanel);
        arrivalTimePanel.add(arrivalDateLabel);
        arrivalTimePanel.add(arrivalDateInfoLabel);
        
        flightPanel.add(arrivalTimePanel);
        arrivalTimePanel.add(arrivalTimeLabel);
        arrivalTimePanel.add(arrivalTimeInfoLabel);
        
        flightPanel.add(seatsAvailablePanel);
        seatsAvailablePanel.add(seatsAvailableLabel);
        seatsAvailablePanel.add(seatsAvailableInfoLabel);
        
        flightPanel.add(pricePanel);
        pricePanel.add(priceLabel);
        pricePanel.add(priceInfoLabel);
        
        flightPanel.add(editFlightDetails);
        flightPanel.setVisible(true);
        
        flightInfoPanel.add(flightPanel);
        
        
        departureInfoLabel.setText("Cairns");
        departureDateInfoLabel.setText("2009-04-08");
        departureTimeInfoLabel.setText("03:15:00");
        destinationInfoLabel.setText("Rockhampton");
        arrivalDateInfoLabel.setText("2009-04-08");
        arrivalTimeInfoLabel.setText("03:14:00");
        seatsAvailableInfoLabel.setText("23");
        priceInfoLabel.setText("129");
        
        flightPanel.add(departurePanel);
        departurePanel.add(departureLabel);
        departurePanel.add(departureInfoLabel);
        
        flightPanel.add(departureDatePanel);
        departureTimePanel.add(departureDateLabel);
        departureTimePanel.add(departureDateInfoLabel);
        
        flightPanel.add(departureTimePanel);
        departureTimePanel.add(departureTimeLabel);
        departureTimePanel.add(departureTimeInfoLabel);
        
        flightPanel.add(destinationPanel);
        destinationPanel.add(destinationLabel);
        destinationPanel.add(destinationInfoLabel);
        
        flightPanel.add(arrivalDatePanel);
        arrivalTimePanel.add(arrivalDateLabel);
        arrivalTimePanel.add(arrivalDateInfoLabel);
        
        flightPanel.add(arrivalTimePanel);
        arrivalTimePanel.add(arrivalTimeLabel);
        arrivalTimePanel.add(arrivalTimeInfoLabel);
        
        flightPanel.add(seatsAvailablePanel);
        seatsAvailablePanel.add(seatsAvailableLabel);
        seatsAvailablePanel.add(seatsAvailableInfoLabel);
        
        flightPanel.add(pricePanel);
        pricePanel.add(priceLabel);
        pricePanel.add(priceInfoLabel);
        
        flightPanel.add(editFlightDetails);
        flightPanel.setVisible(true);
        
        flightInfoPanel.add(flightPanel);
        
        
        departureInfoLabel.setText("Cairns");
        departureDateInfoLabel.setText("2009-05-01");
        departureTimeInfoLabel.setText("03:20:00");
        destinationInfoLabel.setText("Townsville");
        arrivalDateInfoLabel.setText("2009-05-01");
        arrivalTimeInfoLabel.setText("03:25:00");
        seatsAvailableInfoLabel.setText("15");
        priceInfoLabel.setText("299");
        
        flightPanel.add(departurePanel);
        departurePanel.add(departureLabel);
        departurePanel.add(departureInfoLabel);
        
        flightPanel.add(departureDatePanel);
        departureTimePanel.add(departureDateLabel);
        departureTimePanel.add(departureDateInfoLabel);
        
        flightPanel.add(departureTimePanel);
        departureTimePanel.add(departureTimeLabel);
        departureTimePanel.add(departureTimeInfoLabel);
        
        flightPanel.add(destinationPanel);
        destinationPanel.add(destinationLabel);
        destinationPanel.add(destinationInfoLabel);
        
        flightPanel.add(arrivalDatePanel);
        arrivalTimePanel.add(arrivalDateLabel);
        arrivalTimePanel.add(arrivalDateInfoLabel);
        
        flightPanel.add(arrivalTimePanel);
        arrivalTimePanel.add(arrivalTimeLabel);
        arrivalTimePanel.add(arrivalTimeInfoLabel);
        
        flightPanel.add(seatsAvailablePanel);
        seatsAvailablePanel.add(seatsAvailableLabel);
        seatsAvailablePanel.add(seatsAvailableInfoLabel);
        
        flightPanel.add(pricePanel);
        pricePanel.add(priceLabel);
        pricePanel.add(priceInfoLabel);
        
        flightPanel.add(editFlightDetails);
        flightPanel.setVisible(true);
        
        flightInfoPanel.add(flightPanel);
        
        
        departureInfoLabel.setText("Rockhampton");
        departureDateInfoLabel.setText("2009-05-01");
        departureTimeInfoLabel.setText("03:20:00");
        destinationInfoLabel.setText("Townsville");
        arrivalDateInfoLabel.setText("2009-05-01");
        arrivalTimeInfoLabel.setText("03:25:00");
        seatsAvailableInfoLabel.setText("15");
        priceInfoLabel.setText("299");
        
        flightPanel.add(departurePanel);
        departurePanel.add(departureLabel);
        departurePanel.add(departureInfoLabel);
        
        flightPanel.add(departureDatePanel);
        departureTimePanel.add(departureDateLabel);
        departureTimePanel.add(departureDateInfoLabel);
        
        flightPanel.add(departureTimePanel);
        departureTimePanel.add(departureTimeLabel);
        departureTimePanel.add(departureTimeInfoLabel);
        
        flightPanel.add(destinationPanel);
        destinationPanel.add(destinationLabel);
        destinationPanel.add(destinationInfoLabel);
        
        flightPanel.add(arrivalDatePanel);
        arrivalTimePanel.add(arrivalDateLabel);
        arrivalTimePanel.add(arrivalDateInfoLabel);
        
        flightPanel.add(arrivalTimePanel);
        arrivalTimePanel.add(arrivalTimeLabel);
        arrivalTimePanel.add(arrivalTimeInfoLabel);
        
        flightPanel.add(seatsAvailablePanel);
        seatsAvailablePanel.add(seatsAvailableLabel);
        seatsAvailablePanel.add(seatsAvailableInfoLabel);
        
        flightPanel.add(pricePanel);
        pricePanel.add(priceLabel);
        pricePanel.add(priceInfoLabel);
        
        flightPanel.add(editFlightDetails);
        flightPanel.setVisible(true);
        
        flightInfoPanel.add(flightPanel);
        }
        FlightList = flightInfoPanel;*/
        return false;
    }
}


